<template>
	<fui-nav-bar title="设置" @leftClick="leftClick">
		<fui-icon name="arrowleft"></fui-icon>
	</fui-nav-bar>
	<fui-list>
		<fui-list-cell :highlight="false">
			<text>昵称</text>
			<text class="fui-text__explain">张曦梦</text>
		</fui-list-cell>
		<fui-list-cell :highlight="false">
			<text>手机号</text>
			<text class="fui-text__explain">{{ userStore.phone }}</text>
		</fui-list-cell>
	</fui-list>
	<view class="btn">
		<fui-button type="primary" @click="show = true" radius="60rpx" width="90%">退出登录</fui-button>
	</view>
	<fui-actionsheet :show="show" :tips="tips" :itemList="itemList" @click="onExit" @cancel="show = false"></fui-actionsheet>
</template>

<script>
import { defineComponent, reactive, toRefs } from 'vue';
import { useFunctionStore } from '@/store/equipment/index.js';
import { useUserStore } from '../store/user';
export default defineComponent({
	setup() {
		const state = reactive({
			show: false,
			tips: '退出后不会删除任何历史数据，下次登录依然可以使用本账号。',
			itemList: [
				{
					text: '退出登录',
					color: '#FF2B2B'
				}
			]
		});
		//仓库数据
		const userStore = useUserStore();
		const store = useFunctionStore();
		const leftClick = () => {
			store.navigateBack();
		};
		const onExit = () => {
			state.show = false;
			console.log('退出登录');
			uni.removeStorageSync('phone');
			uni.reLaunch({
				url: '/pages/login/index'
			});
			// uni.removeStorageSync('userInfo');
			// uni.setStorageSync('isLogin', false);
		};
		return {
			...toRefs(state),
			leftClick,
			onExit,
			userStore
		};
	}
});
</script>

<style scoped lang="scss">
.btn {
	width: 100%;
	margin-top: 100rpx;
	padding-left: 10%;
	box-sizing: border-box;
}
</style>
